package com.ming.config_client.controller;

import com.sun.corba.se.spi.orbutil.threadpool.ThreadPool;
import org.springframework.context.support.GenericApplicationContext;

import java.beans.Beans;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Auther: tangC
 * @Date: 2020/6/8 17:19
 * @Description:
 */
public class Test implements Runnable {
    static Integer x = 0;
    private Lock lock = new ReentrantLock();

    AtomicInteger num = new AtomicInteger(0);

    int integer = 0;
    @Override
    public void run() {
            while (integer<50000){
                integer++;
                num.addAndGet(1);
                System.out.println(Thread.currentThread().getName()+"线程执行完毕:x="+integer);
        }
//        System.out.println(Thread.currentThread().getName()+"线程执行完毕:x="+integer.get());
    }

    public static void main(String[] args) {

        Test test = new Test();
//        test.run();
        for (int i=0;i<200;i++){
            Thread thread = new Thread(test,"线程"+i);
            thread.start();
        }

       try {
            Thread.sleep(1000);
           System.out.println(test.integer);
           System.out.println(test.num);
       }catch (Exception e){

       }
    }
}
